- title_service_name = "#{@current_community.full_name(I18n.locale)}"

- if content_for?(:title)
  - title = "#{content_for(:title)} - #{title_service_name}"
- else
  - title = social_media_title

- if content_for?(:meta_author)
  - meta_author = content_for(:meta_author)
- else
  - meta_author = @current_community.name(I18n.locale)

- full_url = "#{@current_community.full_url}#{request.fullpath}"

- if content_for?(:meta_description)
  - meta_description = "#{content_for(:meta_description)}"
- else
  - meta_description = social_media_description

- if content_for?(:meta_image)
  - meta_image = content_for(:meta_image)
  - meta_image_width = content_for(:meta_image_width)
  - meta_image_height = content_for(:meta_image_height)
- else
  - if @current_community.social_logo.try(:image).try(:file?)
    - meta_image = @current_community.social_logo.image.url(:original)
  - elsif @current_community.logo?
    - meta_image = @current_community.logo.url(:original)
  - else
    - meta_image = image_path("sharetribe_icon.png")

- default_title = content_for?(:title) ? "#{content_for(:title)} - #{title_service_name}" : "#{title_service_name} - #{community_slogan}"
%title= custom_meta_title(default_title)
%meta{ :property => "og:title", :content => custom_meta_title(title, :social)}
%meta{ :name => "twitter:title", :content => custom_meta_title(title, :social)}
%meta{ :name => "author", :content=> meta_author }
%meta{ :property => "og:url", :content => full_url}
%meta{ :name => "identifier-url", :content => "#{@current_community.full_domain(with_protocol: true)}"}
%meta{ :name => "copyright", :content => "#{@current_community.name(I18n.locale)}"}
%meta{ :name => "twitter:url", :content => full_url}
%meta{ :property => "og:site_name", :content =>"#{@current_community.full_name(locale)}"}
%meta{ :name => "description", :content => strip_tags(custom_meta_description(meta_description))}
%meta{ :property => "og:description", :content => strip_tags(custom_meta_description(meta_description, :social))}
%meta{ :name => "twitter:description", :content => strip_tags(custom_meta_description(meta_description, :social))}
%meta{ :property => "og:image", :content => meta_image}
- if meta_image_width && meta_image_height
  %meta{ :property => "og:image:width", :content => meta_image_width}
  %meta{ :property => "og:image:height", :content => meta_image_height}
%meta{ :name => "twitter:image", :content => meta_image}
%link{:rel => "canonical", :href => full_url}
- if @facebook_locale_code
  %meta{ :property => "og:locale", :content => @facebook_locale_code}

- if @current_community.twitter_handle.present?
  %meta{ :name => "twitter:site", :content => "@#{@current_community.twitter_handle}"}

- if @current_community.facebook_connect_id
  %meta{ :property => "fb:app_id", :content => "#{@current_community.facebook_connect_id}" }

/ CSS
= stylesheet_link_tag "application"

- if @current_community.has_customizations?
  = render partial: "layouts/style_overrides", locals: MarketplaceHelper.style_customizations_map(@current_community)

- if @custom_footer.try(:display?)
  = render 'layouts/footer/css'

= stylesheet_link_tag "app-bundle"

/ Modernizr, in the head tag, right after stylesheets, for best performance:
= javascript_include_tag "modernizr.min"

/ Detect if JS is enabled. duplicate of what Modernizr is doing, but we plan to get rid of Modernizr at some point.
:javascript
  document.documentElement.className += ' js-enabled';


/ Android pre Jellybean has an ugly bug, which prevents font-size 0 technique from
/ removing the spaces between inline-blocks. Remove this piece of code when pre Jellybean becomes unsupported
:javascript
  Modernizr.addTest('androidPreJellybean', function(){
    var ua = navigator.userAgent;
    if( ua.indexOf("Android") >= 0 ) {
      var androidversion = parseFloat(ua.slice(ua.indexOf("Android")+8));
      return androidversion < 4.1
    }
  });

= csrf_meta_tag

%link{:rel => "image_src", :href => meta_image}

%link{:rel => "shortcut icon", :href => @current_community.favicon }

%link{:rel => "apple-touch-icon-precomposed",:href => @current_community.logo.url(:apple_touch)}

= auto_discovery_link_tag(:atom, atom_feed_url )

- unless @disable_custom_head_script || on_admin?
  = @current_community.custom_head_script.try(:html_safe)
